package com.ruoyi.web.controller.zbj;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zbj.domain.RyZbj;
import com.ruoyi.zbj.service.IRyZbjService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 直播间管理Controller
 * 
 * @author lps
 * @date 2024-11-11
 */
@Controller
@RequestMapping("/zbj/manage")
public class RyZbjController extends BaseController
{
    private String prefix = "zbj/manage";

    @Autowired
    private IRyZbjService ryZbjService;

    @RequiresPermissions("zbj:manage:view")
    @GetMapping()
    public String manage()
    {
        return prefix + "/manage";
    }

    /**
     * 查询直播间管理列表
     */
    @RequiresPermissions("zbj:manage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RyZbj ryZbj)
    {
        startPage();
        List<RyZbj> list = ryZbjService.selectRyZbjList(ryZbj);
        return getDataTable(list);
    }

    /**
     * 导出直播间管理列表
     */
    @RequiresPermissions("zbj:manage:export")
    @Log(title = "直播间管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RyZbj ryZbj)
    {
        List<RyZbj> list = ryZbjService.selectRyZbjList(ryZbj);
        ExcelUtil<RyZbj> util = new ExcelUtil<RyZbj>(RyZbj.class);
        return util.exportExcel(list, "直播间管理数据");
    }

    /**
     * 新增直播间管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存直播间管理
     */
    @RequiresPermissions("zbj:manage:add")
    @Log(title = "直播间管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RyZbj ryZbj)
    {
        return toAjax(ryZbjService.insertRyZbj(ryZbj));
    }

    /**
     * 修改直播间管理
     */
    @RequiresPermissions("zbj:manage:edit")
    @GetMapping("/edit/{zbId}")
    public String edit(@PathVariable("zbId") Long zbId, ModelMap mmap)
    {
        RyZbj ryZbj = ryZbjService.selectRyZbjByZbId(zbId);
        mmap.put("ryZbj", ryZbj);
        return prefix + "/edit";
    }

    /**
     * 修改保存直播间管理
     */
    @RequiresPermissions("zbj:manage:edit")
    @Log(title = "直播间管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RyZbj ryZbj)
    {
        return toAjax(ryZbjService.updateRyZbj(ryZbj));
    }

    /**
     * 删除直播间管理
     */
    @RequiresPermissions("zbj:manage:remove")
    @Log(title = "直播间管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(ryZbjService.deleteRyZbjByZbIds(ids));
    }
}
